import {Component} from 'react';
import WithRoute from '../router/withRoute';
import axios from 'axios';
class Home extends Component{
    state = {
        list:[
            
        ]
    }
    render(){
        return(
            <div>
              <h1>首页</h1>
              {
                this.state.list.map((item)=>{
                    return (
                        <div key={item.id} onClick={()=>this.goInfo(item.id)}>
                            <img src={item.image} alt="" style={{width:"100px"}} />
                            <p>{item.storeName}</p>
                        </div>
                    )
                })
              }
            </div>
        )
    }
    async componentDidMount(){
        let res = await axios.get(`https://apif.java.crmeb.net/api/front/index/product/1/?page=1&limit=10`);
        console.log(res)
        this.setState({
            list:res.data.data.list
        })
    }
    goInfo(id){
        this.props.router.navigate("/info",{
            state:{
                id:id
            }
        })
    }
}
export default WithRoute(Home);